package com.example.cloudstorge.config;

import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class AuthInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        // 逻辑认证
        String authorization = request.getHeader("Authorization");
        System.out.println("获取的认证信息 Authorization： = " + authorization);
        if (StringUtils.hasText(authorization)) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {

        String timeString = "21:00";

        // 定义时间格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");

        // 将字符串解析为 LocalTime 对象
        LocalTime localTime = LocalTime.parse(timeString, formatter);

        System.out.println("LocalTime: " + localTime);

    }
}
